const map = new WeakMap();
const observe = new IntersectionObserver((entries, observe) => {
  entries.forEach((entry) => {
    if (entry.isIntersecting) {
      const el = map.get(entry.target);
      const { top, left, width, height } = el.getBoundingClientRect();
      const heightf = parseInt(width / 1.5);
      // 设置el的height属性
      el.style.height = `${heightf}px`;
      observe.unobserve(entry.target);
      console.log("el.style.height", el.style.height);
    }
  });
});


export const handleRect = {
  mounted(el, binding) {
    // 指令逻辑
    map.set(el, el);
    observe.observe(el);
    window.addEventListener("resize", () => {
      // observe.unobserve(el);
      observe.observe(el);
    });
  },
};
